package es

import (
	es "github.com/olivere/elastic/v7"
)

var (
	cli *es.Client
)

const (
	indexUser   = "user-go"
	indexStatus = "status-go"
)

func CheckErr(err error) {
	if err != nil {
		panic(err)
	}
}

func InitClient() {
	addr := []string{
		"http://127.0.0.1:9200",
		"http://127.0.0.1:9201",
		"http://127.0.0.1:9202",
	}

	var err error
	if cli == nil {
		cli, err = es.NewClient(es.SetURL(addr...))
		CheckErr(err)
	}
}
